<?php
namespace Client\Model;
use Think\Model\RelationModel;

class ScenicOrderModel extends RelationModel{
	protected $_link = array(
		'ScenicTicket' =>array(
			'mapping_type'  => self::BELONGS_TO,
			'foreign_key'   => 'ticket_id',
//			'mapping_name'  => 'ticket',
			'mapping_fields'=> 'name,price,image',
			'as_fields'     => 'name:ticket_name,price:ticket_price,image:ticket_image',
		),
		'Scenic' =>array(
			'mapping_type'  => self::BELONGS_TO,
			'foreign_key'   => 'scenic_id',
//			'mapping_name'  => 'scenic',
			'mapping_fields'=> 'phone,name,address,latitude,longitude',
			'as_fields'     => 'phone:scenic_phone,name:scenic_name,address:scenic_address,latitude:scenic_latitude,longitude:scenic_longitude',
		),
	);
	protected $_auto = array (
		array('id','getId',self::MODEL_INSERT,'callback') , // 对id字段在新增的时候自动生成一个ID
		array('createTime','time',self::MODEL_INSERT,'function') , // 对createTime字段在新增时添加当前的时间
	);
	function getId(){
		$util = A('Util');
		return  'O'.$util->getId();//生成用户ID
	}
}